package com.gome.transactiontree.sample.case3;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.gome.transactiontree.api.TransactionNode;

@Service
public class BusinessB {

	private static final Logger LOG = LoggerFactory.getLogger(BusinessB.class);
	
	public static boolean exception = false; 

	@TransactionNode(rollback = "a1_rollback")
	public String b1(String txid, String p2) {
		LOG.info("Compensation BusinessB.b1({},{})", txid, p2);
		
		if (exception) {
			throw new RuntimeException("BusinessB.b1 error");
		}
		
		return txid;
	}

	public void a1_rollback(String txid, String p2) {
		LOG.info("Compensation BusinessB.a1_rollback({},{})", txid, p2);
	}
}